package io.openinstall.unity;

import com.fm.openinstall.listener.*;
import com.fm.openinstall.model.*;
import org.json.*;
import android.util.*;
import com.unity3d.player.*;

public class OiInstallCallback extends AppInstallAdapter
{
    private final String installCallbackMethod;
    private final String installCallbackObject;

    public OiInstallCallback() {
        this.installCallbackObject = "OpenInstall";
        this.installCallbackMethod = "_installCallback";
    }

    @Override
    public void onInstall(final AppData appData) {
        final JSONObject jsonObject = new JSONObject();
        while (true) {
            try {
                jsonObject.put("channelCode", (Object)appData.getChannel());
                jsonObject.put("bindData", (Object)appData.getData());
                this.sendUnityMessage(jsonObject.toString());
            }
            catch (Exception ex) {
                continue;
            }
            break;
        }
    }

    public void sendUnityMessage(final String s) {
        Log.d("OpenInstall", String.format("OiInstallCallback UnitySendMessage(%s, %s, %s)", "OpenInstall", "_installCallback", s));
        UnityPlayer.UnitySendMessage("OpenInstall", "_installCallback", s);
    }
}
